import 'package:architecture/os_size.dart';
import 'package:flutter/material.dart';
import 'package:study_demo/base/theme_controller.dart';

class MyTextButton extends StatelessWidget {
  String? text;
  double? height;
  double? width;
  Color? backgroundColor;
  Color? sideColor;
  EdgeInsets margin;
  TextStyle? textStyle;
  Function? confirm;

  MyTextButton(
      {this.text,
      this.height,
      this.width,
      this.confirm,
      this.textStyle,
      this.backgroundColor,
      this.sideColor,
      this.margin = EdgeInsets.zero});

  @override
  Widget build(BuildContext context) {
    return Container(
        height: height ?? windowHeight * 0.05,
        width: width,
        margin: margin,
        child: TextButton(
          style: TextButton.styleFrom(
              //背景颜色
              backgroundColor: backgroundColor ??
                  (isDarkMode.value ? Colors.transparent : Colors.white),
              shape: const RoundedRectangleBorder(
                  borderRadius: BorderRadius.all(Radius.circular(5))),
              side: BorderSide(
                  color: sideColor ??
                      (isDarkMode.value
                          ? Colors.white
                          : (backgroundColor == null
                              ? Colors.deepPurpleAccent
                              : backgroundColor!)),
                  width: isDarkMode.value ? 0.5 : 0.8)),
          child: Text(text!,
              style: textStyle ??
                  TextStyle(
                      fontFamily: 'SiYuan',
                      color: isDarkMode.value
                          ? Colors.grey
                          : Colors.deepPurpleAccent,
                      fontSize: 15)),
          onPressed: () {
            confirm?.call();
          },
        ));
  }
}
